class CreateAutomatorWorkflows < ActiveRecord::Migration
  def self.up
    create_table :workflow_action_libraries do |t|
      t.column :name, :string
    end
    
    create_table :workflows do |t|
      t.column :name, :string
      t.column :created_by, :integer
      t.column :owner_email, :string
      t.column :mail_report, :boolean
      t.column :period, :string  # day, week, month, year
      t.column :frequency, :integer, :size => 2
      t.column :hour, :integer, :size => 2
      t.column :last_successful_execution_at, :datetime
      t.column :last_attempted_execution_at, :datetime
    end

    create_table :workflow_actions do |t|
      t.column :kind, :string
      t.column :position, :integer
      t.column :workflow_id, :integer
      t.column :quantities, :text
      t.column :operators, :text
      t.column :operands, :text
      t.column :options, :text
    end
    
  end
  
  def self.down
    drop_table :workflow_action_libraries
    drop_table :workflows    
    drop_table :workflow_actions
  end
end